<?php

defined('_JEXEC') or die;

jimport('joomla.application.component.modellist');

class ApkipasModelTags extends JModelList
{
	public function save($data){
	
		// Initialise variables;
		$table = $this->getTable('tags');
		$key = $table->getKeyName();
		$pk = (!empty($data[$key])) ? $data[$key] : (int) $this->getState($this->getName() . '.id');
		$isNew = true;
	
		// Allow an exception to be thrown.
		try
		{
			// Load the row if saving an existing record.
			if ($pk > 0)
			{
				$table->load($pk);
				$isNew = false;
			}
	
			// Bind the data.
			if (!$table->bind($data)){
				$this->setError($table->getError());
				return false;
			}
	
			// Check the data.
			if (!$table->check()){
				$this->setError($table->getError());
				return false;
			}
	
			// Store the data.
			if (!$table->store()){
				$this->setError($table->getError());
				return false;
			}
	
			// Clean the cache.
			$this->cleanCache();
	
		}
		catch (Exception $e){
			$this->setError($e->getMessage());
			return false;
		}
	
		return $table->id;
	}
}